package net.bwie.dt.funtion;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import net.bwie.dt.bean.OrderBean;

import org.apache.flink.api.common.functions.MapFunction;


public class dtBeanMapFuctionOrder implements MapFunction<String, OrderBean> {

    @Override
    public OrderBean map(String s) throws Exception {
        JSONObject jsonObject = JSON.parseObject(s);
        Integer order_id = jsonObject.getInteger("order_id");
        Integer user_id = jsonObject.getInteger("user_id");
        Integer produce_id = jsonObject.getInteger("produce_id");
        Integer quantity = jsonObject.getInteger("quantity");
        Double price = jsonObject.getDouble("price");
        String status = jsonObject.getString("status");
        Double pay_amount = jsonObject.getDouble("pay_amount");
        String pay_time = jsonObject.getString("pay_time");
        Integer is_presale = jsonObject.getInteger("is_presale");
        String presale_stage = jsonObject.getString("presale_stage");
        return new OrderBean(
                order_id
                ,user_id
                ,produce_id
                ,quantity
                ,price
                ,status
                ,pay_amount
                ,pay_time
                ,is_presale
                ,presale_stage
        );
    }
}
